import request from '@/utils/request'

// 查询商品列表列表
export function listList (query) {
  return request({
    url: '/h2-shop-goodsinfo/page',
    method: 'post',
    data: query
  })
}

// 查询商品列表详细
export function getList (goodId) {
  return request({
    url: `/h2-shop-goodsinfo/prdouct/${goodId}`,
    method: 'get'
  })
}

// 新增商品列表
export function addList (data) {
  return request({
    url: '/h2-shop-goodsinfo/add',
    method: 'post',
    data: data
  })
}

// 修改商品列表
export function updateList (data) {
  return request({
    url: '/h2-shop-goodsinfo/upd',
    method: 'post',
    data: data
  })
}

// 修改商品规格属性
export function updateSkuAttr (data) {
  return request({
    url: '/h2-shop-sku/add',
    method: 'post',
    data: data
  })
}

// 删除商品规格属性
export function updateSkuDel (data) {
  return request({
    url: '/h2-shop-sku/del',
    method: 'post',
    data: data
  })
}
// 修改当前行商品规格属性
export function updateSkuUpd (data) {
  return request({
    url: '/h2-shop-sku/upd',
    method: 'post',
    data: data
  })
}
//上下架
export function marketable (id) {
  return request({
    url: `/h2-shop-goodsinfo/${id}`,
    method: 'put',
  })
}

// 删除商品列表
export function delList (id) {
  return request({
    url: `/h2-shop-goodsinfo/${id}`,
    method: 'delete'
  })
}

//添加规格
export function addAttr (data) {
  return request({
    url: `/h2-shop-sku-attribute/save`,
    method: 'post',
    data
  })
}
// 编辑规格属性名

export function editAttr (data) {
  return request({
    url: `/sys/productSkuAttributeOptions/edit`,
    method: 'post',
    data
  })
}
//删除规格
export function removeAttr (id) {
  return request({
    url: `/h2-shop-sku-attribute/${id}`,
    method: 'delete'
  })
}

//添加规格
export function addOption (data) {
  return request({
    url: `/h2-shop-sku-attribute/saveOption`,
    method: 'post',
    data
  })
}

//删除规格
export function removeOption (id) {
  return request({
    url: `/h2-shop-sku-attribute/deleteOption/${id}`,
    method: 'delete'
  })
}
